FLAGS := $(LDFLAGS)
CFLAGS := $(CFLAGS)  -pedantic
CXX= g++

#define OUTPUT_STATISTICS 

BINARY = mre_agent

AGENTSRC = AgentProxy.cpp MREAgent.cpp GridSolver.cpp TFGenerator.cpp FittedVISolver.cpp Grid.cpp KDTree.cpp KDTreeLearner.cpp KNode.cpp LocalRegression.cpp MDPSolver.cpp OriginalRewardGenerator.cpp OriginalTFGenerator.cpp ParamReader.cpp RFGeneralizer.cpp Util.cpp GenericMessage.cpp ValueFunctionRequestMessage.cpp ValueFunctionResponseMessage.cpp 
AGENTOBJ = $(addprefix Build/, $(addsuffix .o, $(basename $(AGENTSRC))))

ENV = ../../env/MountainCar/MountainCar.cpp
ENVOBJ = $(addsuffix .o, $(basename $(ENV))) 

all: $(AGENTOBJ) $(ENVOBJ) 
	${CXX}  $(LDFLAGS) $^ -lm -lrlutils -lrlagent -lrlgluenetdev -o $(BINARY)


Build/%.o: %.cpp
	${CXX}  $(CFLAGS) -o $@  -c $<

clean:
	rm -rf $(BINARY) core* Build/*.o

kill: 
	killall -9 $(BINARY)
run:
	./$(BINARY) 127.0.0.1 4096 > result.out & 
	tailf result.out | grep episode 

